refactor: remove unnecessary asm/ tree copy from standards and agglayer build scripts#2538
refactor: remove unnecessary asm/ tree copy from standards and agglayer build scripts#2538
Conversation
miden-standards: Remove the full asm/ directory copy to OUT_DIR entirely. This crate never mutates its source tree, so the assembler and error extractor can read directly from the crate's asm/ directory. miden-protocol: Replace the bulk copy of the entire asm/ tree with targeted staging of only the two directories that need modification (kernels/transaction/ and protocol/). The assembler requires shared modules to be physically present alongside these source files, but shared_utils/ and shared_modules/ themselves don't need to be copied. Event extraction now reads directly from the original source. Also simplifies copy_dir_recursive (replacing the old copy_directory with its awkward prefix-stripping API) and removes dead code. https://claude.ai/code/session_01HDd5o3XxcgZiGrvBDFsUr1 refactor: scope change to standards build only, leave protocol as-is The protocol crate needs source-level staging because the assembler's `$kernel::` import resolution requires shared modules to be physically co-located with kernel source. This cannot be avoided without assembler changes, so revert the protocol build.rs to the base branch version. https://claude.ai/code/session_01HDd5o3XxcgZiGrvBDFsUr1
|
Something else we can do after #2452 is removing |
Read MASM sources directly from the crate's asm/ directory instead of copying them to OUT_DIR first. The copy is unnecessary because agglayer doesn't mutate the directory structure during compilation. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
asm/ tree copy in standards build script0becf7d to
302dcf0
Compare
| generate_canonical_zeros(&src.join(ASM_AGGLAYER_BRIDGE_DIR))?; | ||
| let crate_path = Path::new(&crate_dir); | ||
| generate_canonical_zeros(&crate_path.join(ASM_DIR).join(ASM_AGGLAYER_BRIDGE_DIR))?; |
There was a problem hiding this comment.
I believe the only two things left writing into src are the canonical zeros and the error constants. Can we generate the error constants in agglayer the same way as in miden-standards, by writing to OUT_DIR?
Then we'd only have the canonical zeros left. These shouldn't really change, right? If so, we could consider generating them with a script once and have the build.rs only validate their correctness without writing into src. Then we would be fully compliant with the "don't write into src policy from rust/cargo" and could remove BUILD_GENERATED_FILES_IN_SRC.
Another strategy for removing the canonical zeros from src is to keep the copy_directory approach for agglayer MASM code. We copy the MASM source to OUT_DIR and generate the canonical zeros directly in the appropriate location within the MASM source code in OUT_DIR. Similar to how the miden-protocol build.rs script creates the kernel and protocol libraries with the shared_utils and account_id.masm. Wdyt?
PR otherwise lgtm 👍
follow up from #2452 (comment)
https://claude.ai/code/session_01HDd5o3XxcgZiGrvBDFsUr1